<?php
session_start(); 
if(!isset($_SESSION['userName'])){
header( 'location:../../index.php' ); 
} 
	include("../../conf/connect.php");
	$user_id = $_SESSION['user_id'];
	$hhid= $_SESSION['usrHHid'];
	$resp_id = $_GET['resp_id'];
	$search_id=$_GET['search_id'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="../../style.css" media="screen" />
	<link rel="shortcut icon" href="images/favicon.ico" />
</head>
<body class="iub_back">
		<table align="center" class="table_border">
			<tr>
					<td class="header"><b class="htext">IUB Survey :: </b><br /><hr /> </td>
			</tr>
			<tr>
					<td> Field : </td>
			</tr>
			<form action="update_operation.php?qus=upd2" method="post">
			<input type="hidden" name="resp_id" value="<?php echo $resp_id;?>" />
			<tr>
					<td>
						<?php
							$sql ="SELECT * FROM adult_question where hid='$hhid' and resp_id=$resp_id";
							$result=mysql_query( $sql);
							while($row = mysql_fetch_array($result)){							
						?>
						<select name="qusNo">
								<?php if($row[spn01_a]=='3'){$loop=1;}else {$loop=6;}
								 for($i=1;$i<=$loop;$i++){?>			
								<option value="<?php echo spn0.$i._a;?>"><?php echo SPN0.$i.A;?></option>
								<?php }	?>
								<?php if($row[spn01_b]=='3'){$loop=1;}else {$loop=6;}
								for($i=1;$i<=$loop;$i++){?>			
								<option value="<?php echo spn0.$i._b;?>"><?php echo SPN0.$i.B;?></option>
								<?php }?>	
								<?php if($row[spn01_c]=='3'){$loop=1;}else {$loop=6;}
								 for($i=1;$i<=$loop;$i++){?>			
								<option value="<?php echo spn0.$i._c;?>"><?php echo SPN0.$i.C;?></option>
								<?php }?>		
								<?php if($row[spn01_d]=='3'){$loop=1;}else {$loop=6;}
								 for($i=1;$i<=$loop;$i++){?>			
								<option value="<?php echo spn0.$i._d;?>"><?php echo SPN0.$i.D;?></option>
								<?php }?>	
								<?php if($row[spn01_e]=='3'){$loop=1;}else {$loop=6;}
								 for($i=1;$i<=$loop;$i++){?>			
								<option value="<?php echo spn0.$i._e;?>"><?php echo SPN0.$i.E;?></option>
								<?php }?>		
						</select>
						<?php }?>
					</td>
			</tr>
			<tr>
					<td align="right" valign="bottom"><input type="submit" value="Update" class="input-box" /> &nbsp;&nbsp;<a href="update.php" class="input-box"> Home &nbsp;&nbsp; </a></td>
			</tr>
			</form>
			<tr>
					<td> Answer(s) :</td>
			</tr>
			<?php
				$sql ="SELECT * FROM adult_question where hid='$hhid' and resp_id=$resp_id";
				$result=mysql_query( $sql);
				while($row = mysql_fetch_array($result)){
				
			?>
			<?php if($row[spn01_a]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>A&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._a;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>A&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._a;
						echo $data=$row["$qus"];
						
						
					?> 
				</td>
			</tr>
			<?php }?> 
			<?php if($row[spn01_b]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>B&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._b;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
			if($row["spn01_b"]=='1'){
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>B&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._b;
						echo $data=$row["$qus"];						
					?> 
				</td>
			</tr>
			<?php } }?> 
			<?php if($row[spn01_c]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>C&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._c;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
			if($row["spn01_c"]=='1'){
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>C&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._c;
						echo $data=$row["$qus"];
						
						
					?> 
				</td>
			</tr>
			<?php } }?>
			<?php if($row[spn01_d]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>D&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._d;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
			if($row["spn01_d"]=='1'){
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>D&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._d;
						echo $data=$row["$qus"];
						
						
					?> 
				</td>
			</tr>
			<?php } }?>  
			<?php if($row[spn01_e]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>E&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._e;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
			if($row["spn01_e"]=='1'){
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>E&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._e;
						echo $data=$row["$qus"];
						
						
					?> 
				</td>
			</tr>
			<?php } }?>
			<?php } ?>
		</table>
		